#ifndef HASH_SEARCH_H
#define HASH_SEARCH_H
#include <unordered_map>

int hashSearch(std::unordered_map<int, int>& hashTable, int x) {
    if (hashTable.find(x) != hashTable.end())
        return hashTable[x];
    return -1;
}

// 使用示例
void exampleUsage() {
    std::unordered_map<int, int> hashTable;
    // 假设我们有一个数组，我们将它转换成哈希表
    int arr[] = {1, 2, 3, 4, 5};
    for (int i = 0; i < 5; ++i) {
        hashTable[arr[i]] = i;
    }
    // 搜索
    int index = hashSearch(hashTable, 3);
    if (index != -1) {
        std::cout << "Element found at index: " << index << std::endl;
    } else {
        std::cout << "Element not found" << std::endl;
    }
}
#endif